import VueDatepickerLocal from "vue-datepicker-local";

/**
 * 载入项目引导文件
 */
require('./bootstrap');

window.Vue = require('vue');

const app = new Vue({
    el: '#wrapper',
    data:{
        table:null,
        searchParams:{
            card_id:'',
            user_card_code:'',
            openid:'',
            outer_str:'',
        },
        box:null,
    },
    mounted:function(){
        let tableOptions = utils.bootstraptableOptions;
        //请求后台的URL
        tableOptions.url = page_params.url_list;
        //搜索参数
        tableOptions.queryParams = (params) => {//传递参数（*）
            //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            var temp = {
                pageSize:params.pageSize,
                page:params.pageNumber,
            };
            return _.merge(temp, this.searchParams);
        };
        tableOptions.columns = [
            {field: 'id'},
            {field: 'card_id',title: '卡券ID',},
            {field: 'user_card_code',title: '卡券Code码',},
            {field: 'user_openid',title: '领券用户openId',},
            {field: 'user.unionid',title: '领券用户unionId',},
            {field: 'user.nickname',title: '用户昵称',},
            {
                field: 'user.headimgurl',title: '头像',
                formatter:function (value, row, index) {
                    if (value){
                        return '<img alt="image" class="img-circle img-sm" src="' + value + '">';
                    }
                }
            },
            {field: 'friend_user_openid',title: '好友用户openId',},
            {
                field: 'is_return_back',title: '是否转赠退回',
                formatter:function (value, row, index) {
                    if (value == 1){
                        return '<span class="label label-info">是</span>';
                    }else{
                        return '<span class="label label-warning">否</span>';
                    }
                }
            },
            {
                field: 'is_chat_room',title: '是否为群转赠',
                formatter:function (value, row, index) {
                    if (value == 1){
                        return '<span class="label label-info">是</span>';
                    }else{
                        return '<span class="label label-warning">否</span>';
                    }
                }
            },
        ];
        this.table = $("#table").bootstrapTable(tableOptions);
    },
    methods: {
        query: function () {
            this.table.bootstrapTable('refresh');
        },
        close:function () {
            layer.close(this.box);
        }
    },
    components: {
    },
});